/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entidades;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author ccedeno
 */
@Entity
@Table(name = "corr_doc_area", catalog = "emilima_tradoc", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CorrDocArea.findAll", query = "SELECT c FROM CorrDocArea c"),
    @NamedQuery(name = "CorrDocArea.findByIdCorrDocArea", query = "SELECT c FROM CorrDocArea c WHERE c.corrDocAreaPK.idCorrDocArea = :idCorrDocArea"),
    @NamedQuery(name = "CorrDocArea.findByFkArea", query = "SELECT c FROM CorrDocArea c WHERE c.corrDocAreaPK.fkArea = :fkArea"),
    @NamedQuery(name = "CorrDocArea.findByFkTipDoc", query = "SELECT c FROM CorrDocArea c WHERE c.corrDocAreaPK.fkTipDoc = :fkTipDoc"),
    @NamedQuery(name = "CorrDocArea.findByAsunto", query = "SELECT c FROM CorrDocArea c WHERE c.asunto = :asunto"),
    @NamedQuery(name = "CorrDocArea.findByFecha", query = "SELECT c FROM CorrDocArea c WHERE c.fecha = :fecha")})
public class CorrDocArea implements Serializable {

    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CorrDocAreaPK corrDocAreaPK;
    @Size(max = 150)
    @Column(name = "asunto", length = 150)
    private String asunto;
    @Column(name = "fecha")
    @Temporal(TemporalType.DATE)
    private Date fecha;
    @JoinColumn(name = "fk_estado", referencedColumnName = "id_estado", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Estado estado;
    @JoinColumn(name = "fk_area", referencedColumnName = "idarea", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Area area;

    public CorrDocArea() {
    }

    public CorrDocArea(CorrDocAreaPK corrDocAreaPK) {
        this.corrDocAreaPK = corrDocAreaPK;
    }

    public CorrDocArea(String idCorrDocArea, String fkArea, String fkTipDoc) {
        this.corrDocAreaPK = new CorrDocAreaPK(idCorrDocArea, fkArea, fkTipDoc);
    }

    public CorrDocAreaPK getCorrDocAreaPK() {
        return corrDocAreaPK;
    }

    public void setCorrDocAreaPK(CorrDocAreaPK corrDocAreaPK) {
        this.corrDocAreaPK = corrDocAreaPK;
    }

    public String getAsunto() {
        return asunto;
    }

    public void setAsunto(String asunto) {
        this.asunto = asunto;
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    public Estado getEstado() {
        return estado;
    }

    public void setEstado(Estado estado) {
        this.estado = estado;
    }

    public Area getArea() {
        return area;
    }

    public void setArea(Area area) {
        this.area = area;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (corrDocAreaPK != null ? corrDocAreaPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CorrDocArea)) {
            return false;
        }
        CorrDocArea other = (CorrDocArea) object;
        if ((this.corrDocAreaPK == null && other.corrDocAreaPK != null) || (this.corrDocAreaPK != null && !this.corrDocAreaPK.equals(other.corrDocAreaPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidades.CorrDocArea[ corrDocAreaPK=" + corrDocAreaPK + " ]";
    }
}
